{extend name="template/base" /}
{block name="content"}
<div class="page-container">
    <form method="get" action="{:\\think\\Url::build($Request.action)}">
        <h3>
            店铺：{$store.name ?? ''}
            {if condition="getAdmin()"}
            <input type="text" id="store_name" readonly onclick="selectStore()"
                value="{$Request.param.store_id|getStoreName}" style="width:200px" class="input-text"
                placeholder="选择店铺">
            <input type="hidden" name="store_id" value="{$Request.param.store_id}">
            <button type="submit" class="btn btn-primary radius mr-5"><i class="Hui-iconfont">&#xe665;</i> 搜索</button>
            {/if}
        </h3>
    </form>

    <h3>基本信息</h3>
    <form class="form form-horizontal" method="post" action="{:\\think\\Url::build('businessSave')}" id="form">
        <input type="hidden" name="store_id" value="{$Request.param.store_id}">
        <table class="table table-border table-bordered table-hover table-bg mt-20">
            <thead>
                <tr class="text-c">
                    <!--<th width="50">序号</th>-->
                    <th width="120">模块</th>
                    <th>内容</th>
                </tr>
            </thead>
            <tbody>

                <!--<tr class="text-c">
                <td>1</td>
                <td>联系方式</td>
                <td><input name="phone" readonly value="{$store.phone ?? ''}  (暂不支持商家修改)" class="input-text" type="tel"></td>
            </tr>-->
                <tr class="text-c">
                    <!--<td>1</td>-->
                    <td>店铺名称</td>
                    <td><input name="tag" value="{$store.name ?? ''}" class="input-text" type="text"
                            placeholder="填写店铺名称"></td>
                </tr>
                <tr class="text-c">
                    <!--<td>2</td>-->
                    <td>店铺地址</td>
                    <td style="float:left;">
                        <input type="hidden" name="province" value="{$store.province ?? ''}">
                        <input type="hidden" name="city" value="{$store.city ?? ''}">
                        <input type="hidden" name="area" value="{$store.area ?? ''}">
                        <span class="dropDown"> <a class="dropDown_A" data-toggle="dropdown" aria-haspopup="true"
                                aria-expanded="true">选择城市</a>
                            <ul class="dropDown-menu menu radius box-shadow">
                                {volist name="address" id="first"}
                                <li><a href="javascript:;">{$first.province_name}</a>
                                    {if condition="!empty($first.city)"}
                                    <ul class="dropDown-menu menu radius box-shadow">

                                        {volist name="first.city" id="second"}
                                        <li>
                                            <a href="javascript:;">{$second.city_name}</a>
                                            {if condition="!empty($second.area)"}
                                            <ul class="dropDown-menu menu radius box-shadow">
                                                {volist name="second.area" id="third"}
                                                <li><a
                                                        href="javascript:selectAddress('{$first.province_name}','{$second.city_name}','{$third}','{$first.province_name}/{$second.city_name}/{$third}');">{$third}</a>
                                                </li>
                                                {/volist}
                                            </ul>
                                            {/if}
                                        </li>
                                        {/volist}

                                    </ul>
                                    {/if}
                                </li>
                                {/volist}
                            </ul>
                        </span>
                        <input type="text" readonly class="input-text" value="{$address_name?? ''}" id="sel-address"
                            placeholder="请点击左边按钮选择" datatype="*" nullmsg="请选择地址" style="width: 200px">

                        <input type="text" class="input-text" value="{$store.detailed_address ?? ''}" placeholder="详情地址"
                            name="detailed_address" style="width: 300px">
                    </td>
                </tr>
                <tr class="text-c">
                    <!--<td>3</td>-->
                    <td>店铺图片</td>
                    <td style="text-align: left;padding-left: 30px">
                        <div class="row cl">
                            <div>
                                <input type="text" readonly class="input-text" name="thumb[]" value="{$thumbs[0] ?? ''}"
                                    id="upload" placeholder="请点击后面的上传按钮" datatype="*" nullmsg="请填写图片url"
                                    style="width: 300px">
                                <button type="button" class="btn btn-primary radius"
                                    onclick="layer_open('文件上传','{:\\think\\Url::build(\'Upload/index\', [\'id\' => \'upload\'])}')">上传</button>
                                <a onclick="$(this).attr('href', 'http://{$Request.host}/public'+$('#upload').val())"
                                    type="button" href="" class="btn btn-success radius"
                                    data-lightbox="example-1">预览</a>
                                <br />
                            </div>
                            <div id="up-box">
                                {volist name="thumbs" id="thumb" key="k"}
                                {if condition="$k!=1"}
                                <div style="margin-top: 5px">
                                    <input type="text" readonly class="input-text" name="thumb[]" value="{$thumb ?? ''}"
                                        id="upload{$k}" placeholder="请点击后面的上传按钮" datatype="*" nullmsg="请填写图片url"
                                        style="width: 300px">
                                    <button type="button" class="btn btn-primary radius"
                                        onclick="layer_open('文件上传','/admin/upload/index/id/upload{$k}.html')">上传</button>
                                    <a onclick="$(this).attr('href', 'http://{$Request.host}/public'+$('#upload{$k}').val())"
                                        type="button" href="" class="btn btn-success radius"
                                        data-lightbox="example-1">预览</a>
                                    <span class="img-del" style="margin-left: 10px;"
                                        onclick="$(this).parent('div').remove()">删除</span>
                                </div>
                                {/if}
                                {/volist}
                            </div>

                            <div style="text-align: right;width: 453px" onclick="addUpImg()">添加</div>
                        </div>
                    </td>
                </tr>





                <tr class="text-c">
                    <!--<td>4</td>-->
                    <td>经营范围</td>
                    <td><input name="engage_in" value="{$store.engage_in ?? ''}" class="input-text" type="text"
                            placeholder="木工板 石膏板 木方"></td>
                </tr>


                <tr class="text-c">
                    <!--<td>4</td>-->
                    <td>店铺标签</td>
                    <td><input name="tag" value="{$store.tag ?? ''}" class="input-text" type="text"
                            placeholder="天利成 五金销售"></td>
                </tr>

                <tr class="text-c">
                    <!-- <td>5</td>-->
                    <td>店铺介绍</td>
                    <td><input name="intro" value="{$store.intro ?? ''}" class="input-text" type="text"
                            placeholder="生产、销售、安装"></td>
                </tr>
                <tr class="text-c">
                    <!--<td></td>-->
                    <td>操作</td>
                    <td class="f-14" style="text-align: left">
                        <button type="submit" class="btn btn-primary radius mr-5">
                            <i class="Hui-iconfont"></i>保存
                        </button>
                    </td>
                </tr>

            </tbody>
        </table>
    </form>

    <h2></h2>

</div>
{/block}
{block name='script'}
<script type="text/javascript" src="__LIB__/Validform/5.3.2/Validform.min.js"></script>
<script>
    $(function () {

        $("#form").Validform({
            tiptype: 2,
            ajaxPost: true,
            showAllError: true,
            callback: function (ret) {
                if (ret.code) {
                    layer.msg("保存失败！");
                } else {
                    layer.msg("保存成功！");
                }
            }
        });
    })
    function selectAddress(fid, sid, tid, str) {
        $('#sel-address').val(str);
        $('input[name=province]').val(fid);
        $('input[name=city]').val(sid);
        $('input[name=area]').val(tid);
    }
    let temp = 0;
    function addUpImg() {
        let imgLen = $('.img-del').length;
        if (imgLen >= 8) return alert("最多能添加9张图片");
        let upload = 'upload' + Math.round(Math.random() * 10000) + (temp++);
        let html = "<div style='margin-top: 5px'><input type=\"text\" readonly class=\"input-text\" name=\"thumb[]\" value=\"{$vo.thumb ?? ''}\" id=\"" + upload + "\" placeholder=\"请点击后面的上传按钮\" datatype=\"*\" nullmsg=\"请填写图片url\" style=\"width: 300px\">\n" +
            "                        <button type=\"button\" class=\"btn btn-primary radius\" onclick=\"layer_open('文件上传','/admin/upload/index/id/" + upload + ".html')\">上传</button>\n" +
            "                        <a onclick=\"$(this).attr('href', 'http://{$Request.host}/public'+$('#" + upload + "').val())\" type=\"button\" href=\"\" class=\"btn btn-success radius\" data-lightbox=\"example-1\">预览</a>\n" +
            "                        <span class='img-del' style=\"margin-left: 10px;\" onclick=\"$(this).parent('div').remove()\">删除</span></div>";
        $('#up-box').append(html);
    }
</script>
{/block}